package com.zyj.myapplication.Fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.zyj.myapplication.Adapter.DashiWentiInfoAdapter;
import com.zyj.myapplication.Javabean.AskList;
import com.zyj.myapplication.Model.CoachModel;
import com.zyj.myapplication.R;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class DashiWentiInfoFragment extends Fragment {

    private RecyclerView recyclerView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.activity_dashi_wenti_info, container, false);
        recyclerView = (RecyclerView) view.findViewById(R.id.dashiwenti_rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));//设置布局
        showData();
        return view;
    }
    private void showData(){
        CoachModel coachModel = new CoachModel();
        Call<List<AskList>> call = coachModel.getAskList("1");
        call.enqueue(new Callback<List<AskList>>() {
            @Override
            public void onResponse(Call<List<AskList>> call, Response<List<AskList>> response) {
                List<AskList> mDataList = response.body();
                recyclerView.setAdapter(new DashiWentiInfoAdapter(DashiWentiInfoFragment.this.getContext(),mDataList));//设置适配器，绑定Adapter.
            }

            @Override
            public void onFailure(Call<List<AskList>> call, Throwable t) {

            }
        });
    }
}